/*
 * QBigHuge
 *
 * A Qt object for retrieving synonyms from
 * Big Huge Thesaurus (http://words.bighugelabs.com)
 * via their REST API.
 *
 * Begin download using fetchSynonyms(QString).
 *
 * Signals:
 *  synonymsReceived(QStringList)   -- successfully downloaded string list
 *  error(QBigHuge::Error, QString) -- error occurred
 *
 * This connection CANNOT be established through a proxy.
 * Define NO_INTERNET to use offline sample file instead.
 * This allows testing at UCT.
 */

#ifndef BIG_HUGE_H
#define BIG_HUGE_H

#include <QString>
#include <QStringList>
#include <QObject>

// forward declarations
class QNetworkAccessManager;
class QNetworkReply;

#define NO_INTERNET // UCT testing

// this sample file is used instead of the internet
// when NO_INTERNET is defined. allows offline
// testing at UCT
#define BIGHUGE_SAMPLE_FILE	"sample.xml"

// Big Huge REST API
#define BIGHUGE_API_KEY		"83d4b5de3d1a0d0791e4519b0b8bb76f/"
#define BIGHUGE_API_URL		"http://words.bighugelabs.com/api/2/"
#define BIGHUGE_API_FORMAT	"/xml"

class QBigHuge : public QObject {
	Q_OBJECT

public:
	// no parent by default
        QBigHuge();

	// download words from remote source
        void fetchSynonyms(const QString& word);

        // various error conditions possible for error signal
        enum Error {NoError = 0, NetworkError, XmlError};

signals:
        // synonyms have been successfully downloaded
        void synonymsReceived(QStringList synonyms);
        // an occurred occurred. see parameters for more info
        void error(const QBigHuge::Error errorCode, const QString& errorString);

private slots:
        // QNetworkManager download has successfully completed
	void finished(QNetworkReply* reply);
};

#endif
